package jjn.weekly;

/**
 * @author Jjn
 * @since 2023/6/25 10:34
 */
public class LeetCode6466 {
    public int countBeautifulPairs(int[] nums) {
        int total = 0;
        for (int i = 0; i < nums.length; i++) {
            int ithNum = nums[i];
            while (ithNum >= 10) {
                ithNum /= 10;
            }
            for (int j = i + 1; j < nums.length; j++) {
                int jthNum = nums[j];
                jthNum = jthNum % 10;
                if (gcd(ithNum, jthNum) < 2) {
                    total++;
                }
            }
        }
        return total;
    }
    
    public int gcd(int a, int b) {
        while (b != 0) {
            int r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
    
    public static void main(String[] args) {
        int[] nums = new int[]{11};
        int countedBeautifulPairs = new LeetCode6466().countBeautifulPairs(nums);
        System.out.println("countedBeautifulPairs = " + countedBeautifulPairs);
    }
    
}
